﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using C_sports_meet.ServiceReference3;
using System.ServiceModel;

namespace C_sports_meet.Athlete
{
    /// <summary>
    /// AQuery.xaml 的交互逻辑
    /// </summary>
    public partial class AQuery : Page, IService1Callback
    {
        private Service1Client client; // 客户端代理类，用于客户端调用服务端方法
        private InstanceContext context; // 让服务端通过InstanceContext知道通信的是哪个客户端对象
        public AQuery()
        {
            InitializeComponent();
            context = new InstanceContext(this); // 获取当前InstanceContext
            client = new Service1Client(context); // 根据InstanceContext创建客户端代理类
        }

        public void ShowResults(DataTable dt, int res)
        {
            throw new NotImplementedException();
        }

        private void SelectBtn1_Click(object sender, RoutedEventArgs e)
        {
            string UserName = Text1.Text;
            DataTable dataset = client.Update(UserName);
            if (dataset == null)
            {
                MessageBox.Show("请输入有效的数据");
            }
            else
            {

                DataGrid1.ItemsSource = dataset.DefaultView;
            }

            Text1.Text = "";
        }

        private void SelectBtn2_Click(object sender, RoutedEventArgs e)
        {
            string UserName = Text2.Text;
            DataTable dataset = client.Update(UserName);
            if (dataset == null)
            {
                MessageBox.Show("请输入有效的数据");
            }
            else
            {

                DataGrid1.ItemsSource = dataset.DefaultView;
            }

            Text1.Text = "";
        }

        private void SelectBtn3_Click(object sender, RoutedEventArgs e)
        {
            string UserName = Text3.Text;
            DataTable dataset = client.Update(UserName);
            if (dataset == null)
            {
                MessageBox.Show("请输入有效的数据");
            }
            else
            {

                DataGrid1.ItemsSource = dataset.DefaultView;
            }

            Text1.Text = "";
        }
    }
}
